package com.yituo.mjworld.mvc.dao;

import com.yituo.mjworld.core.utils.BaseDao;
import com.yituo.mjworld.mvc.entity.web.Product;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class ProductDao extends BaseDao {
  /**
   * 通过UserId和OrderId 获取指定的订单
   *
   * @return 获取成功返回对应的订单对象, 订单不存在返回null
   */
  public Product getGoodsByName(String name) {
    String hql = " from Product where name=:name ";
    Map<String, Object> params = new HashMap<String, Object>(1);
    params.put("name", name);
    List<Product> list = findByHql(hql, params);
    if (list != null && list.size() > 0) {
      return list.get(0);
    }
    return null;
  }

  public Product getProductById(int id) {
    return null;
  }
}
